<template>
    <a-card :bordered="false">
        <div class="table-operator">
            <a-button shape="round" size="small" type="primary" icon="plus" @click="handleEdit({},'roleForm','新增')">添加</a-button>
        </div>

        <LTable
        ref="roleList"
        size="small"
        rowKey="keyId"
        :formAttributes="formAttributes"
        :initOrder="initOrder"
        :columns="columns"
        axiosUrl="/SysRoleController/page"
        :showPagination="true"
        :showQueryForm="true"
      >
      <span slot="roleUse" slot-scope="text,record">
            <a-icon v-if="record.roleUse==1" type="check" :style="{ color: 'green' }"/>
            <a-icon v-else type="close" :style="{ color: 'hotpink',fontSize: '14px'}"/>
      </span>
        <a-icon type="check-circle" />
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record,'roleForm',record.roleName)">编辑</a>
          <a-divider type="vertical" />
          <a @click="handleEdit(record,'roleMenu',record.roleName)">授权</a>
          <a-divider type="vertical" />
          <a @click="handleEdit(record,'rolePerson',record.roleName)">人员</a>
        </span> 
    </LTable>
    <roleForm ref="roleForm" @close="refresh('roleList')" @ok="refresh('roleList')"></roleForm>
    <roleMenu ref="roleMenu"></roleMenu>
    <rolePerson ref="rolePerson"></rolePerson>
    </a-card>
</template>

<script>
import LTable from '@/components/lt/LTable'
import roleForm from './roleForm'
import roleMenu from './roleMenu'
import rolePerson from './rolePerson'
import {SysMixin} from '@/mixins/SysMixin'


export default {
    name:'roleList',
    components:{
       LTable,roleForm,roleMenu,rolePerson
    },
    mixins:[SysMixin],
    data(){
        return{
            formAttributes:[
                {field:'roleName',label:'角色名称',component:'input',condition:'like'},
            ],
            initOrder:[{field:'roleSort',val:'asc'}],
            columns:[
                {
                    title: '序号',
                    dataIndex: '',
                    key:'rowIndex',
                    width:60,
                    align:"center",
                    customRender:function (t,r,index) {
                      return parseInt(index)+1;
                    }
                },
                
                {
                    title: '角色编号',
                    dataIndex: 'roleNo'
                },
                {
                    title: '角色名称',
                    dataIndex: 'roleName'
                    
                },
                {
                    title: '状态',
                    dataIndex: 'roleUse',
                    scopedSlots: { customRender: 'roleUse' }
                },
                {
                    title: '操作',
                    dataIndex: 'action',
                    width: '160px',
                    scopedSlots: { customRender: 'action' }
                }
            ],
            
        }
    },
    created(){
       
    },
    methods:{
        
        
    }
}
</script>